package com.pdg.dungeondelver.engine;

public enum LayerDirections {
	NORTH(0,-1),
	NORTH_EAST(1,-1),
	EAST(1,0),
	SOUTH_EAST(1,1),
	SOUTH(0,1),
	SOUTH_WEST(-1,1),
	WEST(-1,0),
	NORTH_WEST(-1,-1);
	private int deltaRow;
	private int deltaColumn;

	LayerDirections(int theDeltaColumn,int theDeltaRow){
		setDeltaColumn(theDeltaColumn);
		setDeltaRow(theDeltaRow);
	}

	private void setDeltaRow(int theDeltaRow) {
		deltaRow=theDeltaRow;
	}

	private void setDeltaColumn(int theDeltaColumn) {
		deltaColumn=theDeltaColumn;
	}
	public int getNextColumn(int startColumn, int startRow){
		return startColumn + deltaColumn;
	}
	public int getNextRow(int startColumn,int startRow){
		return startRow + deltaRow;
	}
	public LayerDirections next(){
		if(this==NORTH){
			return NORTH_EAST;
		}else if(this==NORTH_EAST){
			return EAST;
		}else if(this==EAST){
			return SOUTH_EAST;
		}else if(this==SOUTH_EAST){
			return SOUTH;
		}else if(this==SOUTH){
			return SOUTH_WEST;
		}else if(this==SOUTH_WEST){
			return WEST;
		}else if(this==WEST){
			return NORTH_WEST;
		}else{
			return NORTH;
		}
	}
	public LayerDirections previous(){
		if(this==NORTH){
			return NORTH_WEST;
		}else if(this==NORTH_EAST){
			return NORTH;
		}else if(this==EAST){
			return NORTH_EAST;
		}else if(this==SOUTH_EAST){
			return EAST;
		}else if(this==SOUTH){
			return SOUTH_EAST;
		}else if(this==SOUTH_WEST){
			return SOUTH;
		}else if(this==WEST){
			return SOUTH_WEST;
		}else{
			return WEST;
		}
	}
	public LayerDirections opposite(){
		if(this==NORTH){
			return SOUTH;
		}else if(this==NORTH_EAST){
			return SOUTH_WEST;
		}else if(this==EAST){
			return WEST;
		}else if(this==SOUTH_EAST){
			return NORTH_WEST;
		}else if(this==SOUTH){
			return NORTH;
		}else if(this==SOUTH_WEST){
			return NORTH_EAST;
		}else if(this==WEST){
			return EAST;
		}else{
			return SOUTH_EAST;
		}
	}
	public static LayerDirections[] getDirections(){
		return new LayerDirections[]{NORTH,NORTH_EAST,EAST,SOUTH_EAST,SOUTH,SOUTH_WEST,WEST,NORTH_WEST};
	}
}
